package net.micedre.courses.controller;

import java.util.logging.Logger;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class IndexController extends Controller {
    static final Logger logger = Logger.getLogger(IndexController.class.getName());
    @Override
    public Navigation run() throws Exception {
        UserService us = UserServiceFactory.getUserService();
        if(us.isUserLoggedIn()){
           User user = us.getCurrentUser();
           requestScope("user", user.getNickname());
           return forward("index.jsp");
 
           
        }
        String loginUri = us.createLoginURL("/");
        return redirect(loginUri);
    }
}
